package com.openlab.service.basic.epidemic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openlab.service.basic.epidemic.dto.UserBuildingDto;
import com.openlab.service.basic.epidemic.entity.UserBuilding;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserBuildingMapper extends BaseMapper<UserBuilding> {
    @Select("select ejyy_user_building.id as user_building_id," +
            "       ejyy_user_building.authenticated," +
            "       ejyy_user_building.authenticated_type," +
            "       ejyy_building_info.type," +
            "       ejyy_building_info.area," +
            "       ejyy_building_info.building," +
            "       ejyy_building_info.unit," +
            "       ejyy_building_info.number," +
            "       ejyy_building_info.id as building_id " +
            "   from ejyy_user_building left join ejyy_building_info on ejyy_building_info.id = ejyy_user_building.building_id" +
            "   where ejyy_user_building.wechat_mp_user_id = #{userId} " +
            "   and ejyy_user_building.status = 1" +
            "   and ejyy_building_info.community_id = #{community_id} " )
    List<UserBuildingDto> selectBuilding(@Param("userId") Long userId, @Param("community_id") Integer community_id);

    @Select("select ejyy_user_building.id," +
            "   ejyy_user_building.building_id," +
            "   ejyy_user_building.wechat_mp_user_id," +
            "   ejyy_user_building.authenticated," +
            "   ejyy_user_building.authenticated_type," +
            "   ejyy_user_building.authenticated_user_id," +
            "   ejyy_user_building.status," +
            "   ejyy_user_building.created_at from ejyy_user_building left join ejyy_building_info on ejyy_building_info.id=ejyy_user_building.building_id " +
            "   where ejyy_user_building.wechat_mp_user_id=#{wechat_mp_user_id} " +
            "   and ejyy_user_building.building_id=#{building_id} " +
            "   and ejyy_building_info.community_id=#{community_id}")
    List<UserBuilding> selectUserBuilding(@Param("wechat_mp_user_id") Long wechat_mp_user_id,@Param("building_id") Long building_id,@Param("community_id") Long community_id);
}
